<layout name="page" />
<block name="content">
	{:widget('page_header/simple',array('name'=>'账户设置'))}
	<div class="space-8"></div>
	<if condition="$auth->write">
		<div class="operate-panel">
			<a class="btn" href="{:url('index')}">返回</a>
			<div class="split"></div>
			<a class="btn" onclick="add()">新建</a>
		</div>
	</if>
	<div class="ul-table">
		<ul>
			<li class="thead">
				<span class="col-10 ">账户名称</span>
				<span class="col-8 ">日期</span>
				<span class="col-16 x1">开户银行</span>
				<span class="col-16 x1">帐号</span>
				<span class="col-8 text-center">初始金额</span>
				<span class="col-8 text-center">账户余额</span>
				<span class="col-8 text-center">操作</span>
				<span class="col-8 ">备注 </span>
			</li>
			<if condition="!empty($list)">
				<li class="no-data">
					没找到数据
				</li>
				<else/>
				<foreach name="list" val="vo">
					<li class="tbody">
						<span class="col-10 "><a href="{:url('edit_account','account_id='.$vo['id'])}">{$vo.name}</a></span>
						<span class="col-8">{$vo.create_time|to_date='Y-m-d'}</span>
						<span class="col-16 x1">{$vo.bank}</span>
						<span class="col-16 x1">{$vo.no}</span>
						<span class="col-8 text-center">{$vo.init}</span>
						<span class="col-8 text-center">{$vo.balance}</span>
						<span class="col-8 text-center"><a data="{$vo.id}" class="del" onclick="del(this);">删除</a></span>
						<span class="col-8  ">{$vo.remark}</span>
					</li>
				</foreach>
			</if>
		</ul>
		<div class="pagination">
			{$page}
		</div>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		layui.use(['global'], function() {
			var $ = layui.jquery;

			set_return_url();

			$("#btn_add").on('click', function() {
				window.open("{:url('add_account')}", "_self");
			});

			$("a.del").on('click', function() {
				id = $(this).attr('data');
				layer.msg('确定要删除吗?', {
					time : 0,
					btn : ['确定', '取消'],
					yes : function(index) {
						var vars = "id=" + id;
						send_ajax("{:url('del_account')}", vars, function(ret) {
							if (ret.status) {
								layer.msg(ret.info, function() {
									location.reload(true);
								});
							}
						});
					},
					no : function(index) {
						layer.close(index);
					}
				});
			});
		});
	</script>
</block>